package com.cy.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.common.exception.ServiceException;
import com.cy.dao.SysGoodsInfoDao;
import com.cy.entity.SysGoodsInfo;
import com.cy.entity.SysGoodsPics;
import com.cy.entity.SysSpecs;
import com.cy.service.SysGoodsInfoService;

@Service
public class SysGoodsInfoServiceImpl implements SysGoodsInfoService {

	@Autowired
	SysGoodsInfoDao sysGoodsInfoDao;

	@Override
	public SysGoodsInfo getGoodsInfo(Integer id) {
		if (id.equals(null)) {
			throw new ServiceException("未找到该商品");
		} else {
			SysGoodsInfo info = sysGoodsInfoDao.findGoodsInfoById(id);
			if (info.equals(null)) {
				throw new ServiceException("没找到商品哦！");
			} else {
				return info;
			}
		}
	}

	@Override
	public List<SysGoodsPics> getGoodsPic(Integer id) {
		if (id.equals(null)) {
			throw new ServiceException("未找到该商品");
		} else {
			List<SysGoodsPics> info = sysGoodsInfoDao.findGoodsPicById(id);
			if (info.equals(null)) {
				throw new ServiceException("该商品没有图片哦！");
			} else {
				return info;
			}
		}
	}

	@Override
	public Map<String, String> getGoodsBrand(Integer id) {
		if (id.equals(null)) {
			throw new ServiceException("未找到该商品");
		} else {
			Map<String, String> info = sysGoodsInfoDao.findGoodsBrandById(id);
			if (info.equals(null)) {
				throw new ServiceException("该商品没有品牌哦！");
			} else {
				return info;
			}
		}
	}

	@Override
	public List<SysSpecs> getGoodsSpecs(Integer id) {

		if (id.equals(null)) {
			throw new ServiceException("未找到该商品");
		} else {
			List<SysSpecs> info = sysGoodsInfoDao.findGoodsSpecsById(id);
			if (info.equals(null)) {
				throw new ServiceException("该商品没有規格哦！");
			} else {
				return info;
			}
		}
	}

}
